package com.jokins.admin.ios.articles.action;

import com.jokins.admin.ios.articles.actioncontext.SaveBookArticlesDoc;
import com.jokins.admin.ios.articles.mapper.BookArticlesMapper;
import com.jokins.admin.ios.articles.param.SaveBookArticlesParam;
import com.jokins.common.actions.action.BaseAction;
import com.jokins.common.actions.exception.BusinessException;
import com.jokins.common.entry.ios.articles.BookArticle;
import com.jokins.common.util.SqlTypeConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 〈〉<br>
 *
 * @author Mr.Wang
 * @create 2025/2/6
 */
@Slf4j
@Component
public class SaveBookArticlesDocAction extends BaseAction<SaveBookArticlesDoc> {

    @Autowired
    private BookArticlesMapper articlesMapper;

    @Override
    protected void process(SaveBookArticlesDoc actionContext) throws BusinessException {
        SaveBookArticlesParam param = actionContext.getParam();
        BookArticle bookArticle = new BookArticle();

        SqlTypeConverter.copyEntity(param, bookArticle);

        articlesMapper.insert(bookArticle);
    }
}